1. Field of the Invention
The present invention relates to a rendering processor, a rasterizer and a rendering method for processing rendering data.
2. Description of the Related Art
A rendering engine in three-dimensional computer graphics is evolving into a programmable, processor-like unit in order to address a complex and advanced shading algorithm. Of particular note is that a pixel shader, which represents a core of a rendering engine, is evolving from hardware with preinstalled, fixed graphics functions, into a processor which has a built-in operation unit provided with instruction sets much like those of a CPU and which allows a program to add functions in a flexible manner.
A programmable pixel shader currently in common use performs polygon setup for a three-dimensional object to be rendered, performs an operation on pixel data obtained by rasterizing polygons, and then computes ultimate color values. A method called multipass rendering is used to achieve highly complex shading. A multipass rendering is a method in which a shading process is divided into a plurality of operation passes and a given rendering primitive is subject to a plurality of different operations. As such, multipass rendering is capable of improving the quality of rendering through advanced fine rendering.
In multipass rendering, a rendering process on a given one or more rendering primitive is divided into a plurality of passes. Since an intermediate operation result in a preceding pass is used in a following pass, a buffer for holding the intermediate result is necessary. Since the buffer for holding the intermediate result is limited in its capacity, it is not possible in each pass to process all rendering primitives at a time. To address this, pixels are divided into blocks each comprising a certain number of pixels. The operation is performed block by block in each pass. For example, given that there are passes 1 through n, the operation is started in pass 1 and continued forward. When the operation in pass n is completed, control proceeds to a next block and then the operation is performed similarly in pass 1 through pass n. By repeating this, multipass rendering is performed on the pixel data for all rendering primitives.
As described, multipass rendering requires a buffer for holding the operation result in a preceding pass until the process in a following pass is performed. Control is required to ensure that the number of pixels processed in a pass does not exceed the limit imposed on the capacity of the buffer so as to prevent buffer overflow from occurring. Meanwhile, it is unknown whether the number of pixels reaches the limit imposed on the capacity of the buffer until the rendering primitives have been rasterized. For example, a rendering primitive at a relatively small distance from a viewpoint is drawn on a screen with a relatively large size. Accordingly, the number of pixels is increased after rasterization.
When it is found after rasterization that buffer overflow occurs, control is required to suspend the ongoing process in a pass and prevent any more pixel data from being input to the pass. In this process, a large quantity of pixel data that has already been rasterized is discarded and wasted accordingly. This is due to the fact that rasterization is performed in units of rendering primitives, while the shading process is performed in units of pixels so that whether or not overflow of a buffer required to hold the operation result of each pass occurs is not known unless the number of pixels is known.
Since pass switching control is performed only when it is known after rasterization that buffer overflow occurs. Therefore, much time is required to acquire parameters of rendering primitives in a following pass, generate the rendering primitives, and perform a setup process. As such, pass switching incurs significant overhead so that processing speed in multipass rendering is decreased. Further, those rendering primitives that are not processed due to the overflow require time to repeat rasterization and generation of pixel data when the process in the pass is resumed.